package com.example.seakdreamandroid.train;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.seakdreamandroid.R;
import com.example.seakdreamandroid.cardQuest.CardQuestionActivity;
import com.example.seakdreamandroid.entity.User;

public class Train extends Fragment {
    private Button button;
    User user;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.item_train,container,false);
        button = view.findViewById(R.id.train);
        user = (User)getContext().getApplicationContext();
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                new Thread(new Runnable() {
//                    @Override
//                    public void run() {
//                        Toast.makeText(view.getContext(),"只要688 失眠离开你",Toast.LENGTH_SHORT).show();
//                    }
//                }).start();
                if(user.getIf_vip().equals("1")){
                    Intent intent = new Intent(view.getContext(), CardQuestionActivity.class);
                    startActivity(intent);
                }else {
                    Toast.makeText(getActivity(), "请充值vip", Toast.LENGTH_SHORT).show();
                }

            }
        });
        return view;
    }
}
